package com.example.springblogdemo.Pojo.Response;

import com.example.springblogdemo.Enums.ResultCodeEnum;
import lombok.Data;

@Data
public class Result {
    private ResultCodeEnum code;
    private String errmsg;
    private Object data;
    public static Result success( Object data) {
        Result result = new Result();
        result.setCode(ResultCodeEnum.SUCCESS);
        result.setData(data);
        return result;
    }
    public static Result fail(String errmsg) {
        Result result = new Result();
        result.setCode(ResultCodeEnum.FAIL);
        result.setErrmsg(errmsg);
        return result;
    }
    public static Result fail(String errmsg, Object data) {
        Result result = new Result();
        result.setCode(ResultCodeEnum.FAIL);
        result.setErrmsg(errmsg);
        result.setData(data);
        return result;
    }
}
